class person {
  String? name;
  int age = 20;
  // person() {
  //   print("构造一个person");
  // }
  person(this.name, this.age) {}
  // person({required name, required age}) {
  //   this.name = name;
  //   this.age = age;
  // }
  // person.now() {
  //   print("命名构造");
  // }
  void getinfo() {
    print("${this.name}--${this.age}");
  }
}

class web extends person {
  String sex = "男";

  web(super.name, super.age, this.sex);

  void info() {
    print('${this.name},${this.age},${this.sex}');
  }

  @override
  void getinfo() {
    print("${this.name}--${this.age}");
  }
}

abstract class Animal {
  eat();
}

class cat extends Animal {
  @override
  eat() {
    print('-----🐟----');
  }
}

abstract class Db {
  String? uri;
  add();
  save();
  delete();
}

class Mysql implements Db, Animal {
  @override
  add() {
    print('这是Mysql add');
  }

  @override
  delete() {
    print('这是Mysql delete');
  }

  @override
  save() {
    print('这是Mysql save');
  }

  @override
  String? uri;

  @override
  eat() {
    print('eat');
  }
}

// 定义一个泛型放法
T getdata<T>(T data) {
  print('这是一个泛型实现');
  return data;
}

class person2 {
  String? name;
  int age;

  person2({required this.name, required this.age}) {}

  getinfo() {
    print('${this.name}, ${this.age}');
  }
}

void main(List<String> args) {
  print("hello \ndsadas");

  print('入参 -- > $args  数量: ${args.length}');

  List l1 = ['1', '2', '3', '4'];

  print(l1);
  print(l1.reversed);
  var l2 = l1.reversed.toList();

  print(l2);

  int myadd(var a, var b) {
    return a + b;
  }

  print(myadd(12, 13));

  String personInfo(String name, [int? age = 5]) {
    if (age == Null) {
      return "$name";
    }
    return "$name -- $age";
  }

  String personInfo1(String name, {int? age = 5, int? U}) {
    if (age == Null) {
      return "$name";
    }
    return "$name -- $age  --- $U";
  }

  print(personInfo('张三'));
  print(personInfo1('张三', U: 4, age: 55));

  List l3 = ["22", "22", "22", "22"];
  l3.forEach((element) {
    print(element);
  });

  person p2 = new person("huhu", 22);
  p2.getinfo();
  person2 p3 = new person2(name: 'zhansan', age: 22);
  p3.getinfo();

  web w1 = new web("胡汉三", 12, '女');
  w1.getinfo();

  cat c = new cat();
  c.eat();

  Animal c1 = new cat();
  c1.eat();

  Mysql mysql1 = new Mysql();
  mysql1.add();

  // 使用泛型
  var res1 = getdata<String>('你好');
  print(res1);
  res1 = getdata<int>(1212).toString();
  print(res1);

  String str1 = 'hh';
  print(str1);

  final final_a;
  final_a = 3;
  print(final_a);
  print(identical(final_a, res1));

  var identical_1 = const Object();
  var identical_2 = const Object();

  print(identical(identical_1, identical_2));
}
